import { defineStore } from "pinia";

import { T_SocketPipelineWarnReason } from "@/pages/event-warn/types";

import type { T_DeviceVideoSearch } from "@/data-services/api/types";

import { warnStatistics } from "@/data-services/api/index";

interface T_CameraWarn_Config {
  warnVideoList: Array<{
    cameraIp?: string;
    videoList: T_SocketPipelineWarnReason[];
  }>;
}

const cameraWarnConfigStore = defineStore("cameraWarnConfig", {
  state(): T_CameraWarn_Config {
    return {
      warnVideoList: [],
    };
  },
  getters: {},
  actions: {
    async getWarnStatistics(seachData: T_DeviceVideoSearch): Promise<any> {
      let res;
      const params = {
        condition: {
          ...seachData,
        },
      };
      try {
        res = await warnStatistics(params);
        return res;
      } catch (error) {
        // console.log(error)
        return error;
      }
    },
  },
});

export const cameraWarnConfig = cameraWarnConfigStore;
